
package botlab.control;

import botlab.command.BaseCommand;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;

/**
 *
 * @author Quentin
 */
public class CommandControl extends BaseControl
{
    BaseCommand command;

    public BaseCommand getCommand()
    {
        return command;
    }

    public void setCommand(BaseCommand command)
    {
        this.command = command;
    }


    @Override
    protected void controlUpdate(float tpf)
    {
        if (isEnabled() && command!=null)
        {
            //New command...
            command.doCommand(spatial,tpf);
        }
    }

    @Override
    public Control cloneForSpatial(Spatial spatial)
    {
        CommandControl control = new CommandControl();
        // set custom properties
        control.setSpatial(spatial);
        control.setEnabled(isEnabled()); 
        // set some more properties here...
        return control;
    }   
}